#include <iostream>
using std::cout; 
using std::endl;
#include <string>
using std::string;
#include <fstream>
#include "bundle.h"

int main(int argc , char* argv[])
{
  if (argc < 3)
  {
    cout << "no enough arguements" << endl;
    return -1;
  }

  string ifilestring = argv[1];
  string ofilestring = argv[2];

  // open and copy the file 
  std::ifstream ifs; 
  ifs.open(ifilestring , std::ios::binary);
  ifs.seekg(0 , std::ios::end);
  size_t size = ifs.tellg();
  ifs.seekg(0 , std::ios::beg);
  string body;
  body.resize(size);
  ifs.read(&body[0] , size);

  // uncompress
  string unpacked = bundle::unpack(body);

  // write to ofilestring 
  std::ofstream ofs;
  ofs.open(ofilestring , std::ios::binary);
  ofs.write(&unpacked[0] , unpacked.size());

  // close stream 
  ifs.close();
  ofs.close();
  return 0;
}
